<?php 
  require(dirname(__FILE__)."/global.php");
  require(dirname(__FILE__)."/isLogin.php");
  
  $submit = $_POST['submit'];
  if(isset($submit))
  {
      $dels = $_POST['del'];
      $cates = $_POST['cate'];
      $i = 0;
      foreach($dels as $del)
      {
          $temp = explode('@',$del);
          if($temp[0] == 'del')
          {
              $sql = "delete from talking_bar where BarID = '$temp[1]'";
              $db->execute($sql);
          }
          else if($temp[0] == 'pass')
          {  
              $sql = "update talking_bar set CateID='$cates[$i]' where BarID = '$temp[1]'";
              $db->execute($sql);
          }
          $i++; 
          
      }
      $smarty->assign('tip','提交成功');                                                  
  }
  $sql ="SELECT tb.*,tu.UserName FROM talking_bar tb,talking_user tu where (CateID is null or CateID = '') and tb.BarAdmin = tu.UserID order by tb.BarCreateTime desc";
  $bars = $db->query($sql);
  $sql ="SELECT * FROM talking_cate order by CateOrderNo";
  $cates = $db->query($sql);
      
  $smarty->assign('bars',$bars);
  $smarty->assign('cates',$cates);
  $smarty->display('bar_approve.html');
  $db->close();
?>